package com.bobo.serviceship.controller;

import com.bobo.serviceship.dao.TbShipDao;
import com.bobo.serviceship.entry.TbShip;
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.codingapi.txlcn.tc.annotation.TccTransaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author bobo
 * @date 2021-04-07
 */
@RestController
public class ShipController {

    @Autowired
    private TbShipDao tbShipDao;

    private TbShip tbShip;

    @GetMapping("/ship")
    @TccTransaction
    public String ship() {
        tbShip = new TbShip();
        tbShip.setId(1);
        tbShip.setAddress("aa");
        tbShipDao.insert(tbShip);
//        int i=1/0;
        return "success";
    }

    public void confirm() {
        System.out.println("确认");
    }

    public void cancel() {
        System.out.println("取消");
        tbShipDao.deleteByPrimaryKey(tbShip.getId());
    }
}
